import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { TranslateService } from '@ngx-translate/core'
import { Observable } from 'rxjs'
import { DEFAULT_LANG, I18N_LANGUAGES } from '../config/language-config'
import { AuthGuardService } from './@core/auth-guard-service.guard'
import { UserAuthService } from './@core/user-auth.service'

@Component({
  selector: 'da-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  currentLang =
    localStorage.getItem('lang') ||
    window.navigator.language.toLowerCase() ||
    DEFAULT_LANG
  i18nValues: any //国际化变量
  linkLabTitie: string = ''
  bottomText = []
  rotateDegrees = 0
  userName = localStorage.getItem('userName')
  count: Observable<number>

  constructor(
    private translate: TranslateService,
    public authGuardService: AuthGuardService,
    public userAuthService: UserAuthService,
    private router: Router
  ) {
    this.translate.addLangs(I18N_LANGUAGES)
    translate.setDefaultLang(DEFAULT_LANG)
    translate.use(this.currentLang)
  }

  ngOnInit() {
    this.i18nValues = this.translate.instant('pages')
    this.linkLabTitie = this.i18nValues['link']['blockchainLab']
  }

  onToggle(event) {
    this.rotateDegrees = event ? 180 : 0
  }
}
